{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f708d3e6",
   "metadata": {},
   "outputs": [],
   "source": [
    "id=['1','2','3','4']                                      \n",
    "books=['三体','三体2','三体3','Python入门']      #书名\n",
    "prices=['66','80','44','99']                                  \n",
    "stocks=['10','15','33','21']\n",
    "\n",
    "user=[['',''],['Tom','66asda216']]                           \n",
    "\n",
    "def dd1():                                                 \n",
    "    d1=input(\"请输入用户名:\")\n",
    "    d2=input(\"请输入密码:\")\n",
    "    if [d1,d2] in user:\n",
    "        ui()\n",
    "        global b\n",
    "        bb=0\n",
    "    else:\n",
    "        print(\"输入错误，请重新登录！\")\n",
    "\n",
    "def ruku():                                                    \n",
    "    a2 = input(\"请输入想要入库的图书名字:\")\n",
    "    a3 = input(\"请输入想要入库的图书价格:\")\n",
    "    a4 = input(\"请输入想要入库的图书库存:\")\n",
    "    id.append(str(len(id)+1))\n",
    "    books.append(a2)\n",
    "    prices.append(a3)\n",
    "    stocks.append(a4)\n",
    "    for i in range(len(id)):\n",
    "        print('',id[i],'\\t  ',books[i],'\\t\\t ',prices[i], '\\t\\t ',stocks[i])\n",
    "\n",
    "    print(\"录入成功！\")\n",
    "        \n",
    "def dd2():                                                    \n",
    "    dd1=input(\"请输入要注册的用户名:\")\n",
    "    dd2=input(\"请输入要注册的密码:\")\n",
    "    user.append([dd1,dd2])\n",
    "    print(\"注册成功！\")\n",
    "\n",
    "\n",
    "\n",
    "bb=1\n",
    "def begin():                                                   \n",
    "    global bb\n",
    "    while bb==1:\n",
    "\n",
    "        print(\"      欢迎来到图书管理信息系统1.登    录 2.注    册 3.退    出      \")\n",
    "        ss = input(\"请选择您的操作:\")\n",
    "\n",
    "        if int(ss) ==1:\n",
    "            dd1()\n",
    "        elif int(ss)==2:\n",
    "            dd2()\n",
    "        else:\n",
    "            bb=0\n",
    "\n",
    "\n",
    "def showall():                                                \n",
    "    print('序 号', '\\t\\t','书 名','\\t\\t\\t', '价 格','\\t\\t', '库 存')\n",
    "    for i in range(len(id)):\n",
    "        print('',id[i],'\\t  ',books[i],'\\t\\t ',prices[i], '\\t\\t ',stocks[i])\n",
    "a=1\n",
    "def tuichu():                                                   \n",
    "    global a\n",
    "    a=0\n",
    "    print(\"成功退出图书管理信息系统！\")\n",
    "\n",
    "\n",
    "\n",
    "def chuku():\n",
    "    b1 = int(input(\"请输入需要删除的图书号:\"))\n",
    "    del id[b1-1]\n",
    "    del books[b1 - 1]\n",
    "    del prices[b1 - 1]\n",
    "    del stocks[b1 - 1]\n",
    "    for i in range(len(id)):\n",
    "        print('',id[i],'\\t  ',books[i],'\\t\\t ',prices[i], '\\t\\t ',stocks[i])\n",
    "    print(\"图书删除成功！\")\n",
    "\n",
    "def gengxin():           \n",
    "    print(id)\n",
    "    c1 = input(\"请输入需要更新的图书序号(0不用输入):\")\n",
    "    ff = int(c1) -1 \n",
    "    c6 = input(\"请输入更新后的图书名字:\")\n",
    "    c7 = input(\"请输入更新后的图书价格:\")\n",
    "    c8 = input(\"请输入更新后的图书库存:\")    \n",
    "    books[ff]=c6\n",
    "    prices[ff]=c7\n",
    "    stocks[ff]=c8\n",
    "    for i in range(len(id)):\n",
    "        print('',id[i],'\\t  ',books[i],'\\t\\t ',prices[i], '\\t\\t ',stocks[i])\n",
    "    print(\"图书更新成功！\")\n",
    "\n",
    "def ui():\n",
    "    while a==1:\n",
    "\n",
    "        print(\"      欢迎使用图书管理信息系统        \")\n",
    "        print(\"1.查看图书               \")\n",
    "        print(\"2.图书入库               \")\n",
    "        print(\"3.图书出库               \")\n",
    "        print(\"4.更新图书               \")\n",
    "        print(\"5.退    出               \")\n",
    "        s=input(\"请选择您的操作:\")\n",
    "        if int(s)==1:\n",
    "            showall()\n",
    "        elif int(s)==2:\n",
    "            ruku()\n",
    "        elif int(s)==3:\n",
    "            chuku()\n",
    "        elif int(s)==4:\n",
    "            gengxin()\n",
    "        elif int(s)==5:\n",
    "            tuichu()\n",
    "        else:\n",
    "            print(\"输入错误,请重新输入！\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
